<?php
/**
 * Created by PhpStorm.
 * User: 1
 * Date: 2017-03-20
 * Time: 17:33
 */

namespace app\src\sunsun\filterVat\helper;


use app\src\base\helper\ValidateHelper;
use app\src\sunsun\filterVat\logic\FilterVatDeviceLogic;
use sunsun\decoder\SunsunTDS;

class FilterVatEncodeHelper
{
    public static function encode($did,$data){
        $result = (new FilterVatDeviceLogic())->getInfo(['did'=>$did]);
        $pwd = "";
        if(ValidateHelper::legalArrayResult($result)){
            $pwd = $result['info']['pwd'];
        }

        if(empty($pwd)){
           return false;
        }

        return SunsunTDS::encode($data,$pwd);
    }
}